﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace WindowsGame1
{
    class Object2D
    {
        public enum ObjectStatus
        {
            Idle,
            Active,
            Removed // When it's removed, the object should be removed from the heap
        }

        protected Color DrawColor;
        protected Vector2 Origin;

        public ObjectStatus Status;
        public Texture2D Texture;
        public Vector2 Position;
        public float RotationAngle;
        public float Scale;
        public byte Opacity { get { return DrawColor.A; } set { DrawColor.A = value; DrawColor.R = value; DrawColor.G = value; DrawColor.B = value; } }
        public int Width { get { return Texture.Width; } }
        public int Height { get { return Texture.Height; } }
        public Rectangle BoundingBox { get { return new Rectangle((int)(Position.X - Width / 2), (int)(Position.Y - Height / 2), Width, Height); } }

        public void Initialize(Texture2D texture, Vector2 position)
        {
            this.Status = ObjectStatus.Active;
            this.DrawColor = Color.White;
            this.Opacity = 0xff;
            this.Texture = texture;
            this.Position = position;
            this.Origin = new Vector2(((float)Width) / 2f, ((float)Height) / 2f);
            this.RotationAngle = 0f;
            this.Scale = 1f;
        }

        public virtual void Update(GameTime gameTime)
        {

        }

        public virtual void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Texture, Position, null, DrawColor, RotationAngle, Origin, Scale, SpriteEffects.None, 0f);
        }
    
    }
}
